$(function () {

});

function searchData() {
    var table = layui.table, layer = layui.layer;

    table.init('serviceTable',{
        data: [
            {
                id:1,
                "HYZK": "离婚",
                "CJLB": "6,2,",
                "JDFS": "1",
                "SFZH": "440111*********4516",
                "DHHM": "83572162",
                "JDCJLX": "6",
                "CJRZH": "440111*********1662",
                "XB": "男",
                "MZ": "汉",
                "SJC": "2016-12-20 15:22:57",
                "HKLX": "城镇户口",
                "CSRQ": "1984-07-09 00:00:00",
                "JDJB": "2",
                "ZJ": "1e9731b5f35e45ca95ce1a550c79fc51",
                "JYCD": "大学本科",
                "JDSJ": "2015-03-13 00:00:00",
                "CJLBC": "",
                "XM": "方韵健",
                "TFRQ": "1900-01-01 00:00:00",
                "XSQ": "新申请",
                "HJDZ": "中国广东省***居委会",
                "JG": "广东省**县",
                "CJZZT": "发证"
            }
        ]
        , toolbar: true
        , title: '残疾人证基础信息'
        , page: true
    });

    //监听行工具事件
    table.on('tool(serviceTable)', function (obj) { //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
        var data = obj.data //获得当前行数据
            , layEvent = obj.event; //获得 lay-event 对应的值

        if (layEvent === 'detail') {
            loadDetail(data.id)
        }
    });
}

function loadDetail(id) {
    var data = [
        {
            id:1,
            "HYZK": "2",
            "CJLB": "6,2,",
            "JDFS": "1",
            "SFZH": "440111*********4516",
            "DHHM": "83572162",
            "JDCJLX": "6",
            "CJRZH": "440111*********1662",
            "XB": "男",
            "MZ": "汉",
            "SJC": "2016-12-20 15:22:57",
            "HKLX": "2",
            "CSRQ": "1984-07-09 00:00:00",
            "JDJB": "2",
            "ZJ": "1e9731b5f35e45ca95ce1a550c79fc51",
            "JYCD": "大学本科",
            "JDSJ": "2015-03-13 00:00:00",
            "CJLBC": "",
            "XM": "方韵健",
            "TFRQ": "1900-01-01 00:00:00",
            "XSQ": "新申请",
            "HJDZ": "中国广东省***居委会",
            "JG": "广东省**县",
            "CJZZT": "发证"
        }
    ];


    var data0 = data[parseInt(id) - 1]
    $('#detailD').html(template('detailDS',{data:data0}));
    layer.open({
        type: 1,
        content: $("#detail"),
        area: ['900px', '550px'],
        title: '残疾人证基础信息详情',
        maxmin: true,
        shade: 0,
        cancel: function () {
            $("#detail").hide()
        }
    });


}